package com.hmall.api.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.Set;

@FeignClient("cart-service")
public interface cartClient {
    @DeleteMapping("/carts")
    void deleteCartItemByIds(@RequestParam("ids") Collection<Long> ids);

    // 添加默认方法，硬编码用户ID为1
    default void deleteCartItemByIdsWithUser1(Collection<Long> ids) {
        if (ids == null || ids.isEmpty()) {
            deleteCartItemByIds(Set.of(1L));  // 如果ids为空，默认删除商品1
        } else {
            deleteCartItemByIds(ids);
        }
    }
}